#ifndef _SAMPLE_H
#define _SAMPLE_H

#include <string>
#include <cstdlib>
#include <sstream>

using namespace std;

class Sample {
public:
    string toString();

    int getDimension() const {
        return m_dim;
    }

    int getClass() const {
        return m_class;
    }

    void setClass(int _class) {
        m_class = _class;
    }

    /** Evaluate the feature data from float array data index by index. */
    void assignFeature(float *data);
    void assignFeature(int index, float data) {
        m_feature[index] = data;
    }

    float * getFeature() const {
        return m_feature;
    }

protected:
    /** Only SampleSpace has the access to this property, for sample's dimension is only decided by sample space. */
    int m_dim;

    int m_class;

    float *m_feature;

    Sample(int dim) {
        m_dim = dim;
        m_class = -1;
        m_feature = new float[m_dim];
    }

    Sample(int dim, int _class) {
        m_dim = dim;
        m_class = _class;
        m_feature = new float[m_dim];
    }

    Sample(int dim, int _class, float *data) {
        m_dim = dim;
        m_class = _class;
        m_feature = new float[m_dim];
        assignFeature(data);
    }

    Sample(const Sample &sample) {
        m_dim = sample.m_dim;
        m_class = sample.m_class;
        m_feature = new float[m_dim];
        assignFeature(sample.m_feature);
    }

    virtual ~Sample() {
        delete []m_feature;
    }

};

#endif
